# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models


class Migration(SchemaMigration):

    def forwards(self, orm):
        # Adding model 'DailySummary'
        db.create_table(u'news_dailysummary', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('date', self.gf('django.db.models.fields.DateField')()),
            ('category', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('edition', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('top_keywords', self.gf('django.db.models.fields.CharField')(max_length=200, blank=True)),
            ('doc_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('positive_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('negative_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('neutral_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('domain_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
        ))
        db.send_create_signal(u'news', ['DailySummary'])

        # Adding unique constraint on 'DailySummary', fields ['date', 'category', 'edition']
        db.create_unique(u'news_dailysummary', ['date', 'category', 'edition'])

        # Adding model 'NewsDetail'
        db.create_table(u'news_newsdetail', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('date', self.gf('django.db.models.fields.DateField')(db_index=True)),
            ('category', self.gf('django.db.models.fields.CharField')(max_length=10)),
            ('url_hash', self.gf('django.db.models.fields.CharField')(max_length=32, db_index=True)),
            ('url', self.gf('django.db.models.fields.URLField')(max_length=200)),
            ('title', self.gf('django.db.models.fields.CharField')(max_length=50)),
            ('publisher', self.gf('django.db.models.fields.CharField')(max_length=100)),
            ('published_time', self.gf('django.db.models.fields.DateTimeField')()),
            ('keywords', self.gf('django.db.models.fields.CharField')(max_length=200, blank=True)),
            ('polarity', self.gf('django.db.models.fields.IntegerField')(default=-1)),
            ('static_summary', self.gf('django.db.models.fields.TextField')(blank=True)),
            ('add_succeeded', self.gf('django.db.models.fields.BooleanField')(default=False)),
        ))
        db.send_create_signal(u'news', ['NewsDetail'])

        # Adding unique constraint on 'NewsDetail', fields ['date', 'category', 'url_hash']
        db.create_unique(u'news_newsdetail', ['date', 'category', 'url_hash'])

        # Adding index on 'NewsDetail', fields ['date', 'category']
        db.create_index(u'news_newsdetail', ['date', 'category'])

        # Adding model 'NewsStocksMap'
        db.create_table(u'news_newsstocksmap', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('news', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['news.NewsDetail'])),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
        ))
        db.send_create_signal(u'news', ['NewsStocksMap'])

        # Adding unique constraint on 'NewsStocksMap', fields ['news', 'stock']
        db.create_unique(u'news_newsstocksmap', ['news_id', 'stock_id'])

        # Adding model 'NewsClusters'
        db.create_table(u'news_newsclusters', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('news', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['news.NewsDetail'])),
            ('edition', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('cluster_id', self.gf('django.db.models.fields.IntegerField')()),
        ))
        db.send_create_signal(u'news', ['NewsClusters'])

        # Adding unique constraint on 'NewsClusters', fields ['news', 'edition', 'cluster_id']
        db.create_unique(u'news_newsclusters', ['news_id', 'edition', 'cluster_id'])

        # Adding model 'ClusterSummary'
        db.create_table(u'news_clustersummary', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('daily_summary', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['news.DailySummary'])),
            ('cluster_id', self.gf('django.db.models.fields.IntegerField')()),
            ('keywords', self.gf('django.db.models.fields.CharField')(max_length=200, blank=True)),
            ('doc_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('positive_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('negative_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('neutral_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('display_news', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['news.NewsDetail'])),
        ))
        db.send_create_signal(u'news', ['ClusterSummary'])

        # Adding unique constraint on 'ClusterSummary', fields ['daily_summary', 'cluster_id']
        db.create_unique(u'news_clustersummary', ['daily_summary_id', 'cluster_id'])

        # Adding model 'StockSummary'
        db.create_table(u'news_stocksummary', (
            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
            ('stock', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['basic_info.Stock'])),
            ('date', self.gf('django.db.models.fields.DateField')()),
            ('edition', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('doc_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('positive_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('negative_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
            ('neutral_count', self.gf('django.db.models.fields.IntegerField')(default=0)),
        ))
        db.send_create_signal(u'news', ['StockSummary'])

        # Adding unique constraint on 'StockSummary', fields ['stock', 'date', 'edition']
        db.create_unique(u'news_stocksummary', ['stock_id', 'date', 'edition'])


    def backwards(self, orm):
        # Removing unique constraint on 'StockSummary', fields ['stock', 'date', 'edition']
        db.delete_unique(u'news_stocksummary', ['stock_id', 'date', 'edition'])

        # Removing unique constraint on 'ClusterSummary', fields ['daily_summary', 'cluster_id']
        db.delete_unique(u'news_clustersummary', ['daily_summary_id', 'cluster_id'])

        # Removing unique constraint on 'NewsClusters', fields ['news', 'edition', 'cluster_id']
        db.delete_unique(u'news_newsclusters', ['news_id', 'edition', 'cluster_id'])

        # Removing unique constraint on 'NewsStocksMap', fields ['news', 'stock']
        db.delete_unique(u'news_newsstocksmap', ['news_id', 'stock_id'])

        # Removing index on 'NewsDetail', fields ['date', 'category']
        db.delete_index(u'news_newsdetail', ['date', 'category'])

        # Removing unique constraint on 'NewsDetail', fields ['date', 'category', 'url_hash']
        db.delete_unique(u'news_newsdetail', ['date', 'category', 'url_hash'])

        # Removing unique constraint on 'DailySummary', fields ['date', 'category', 'edition']
        db.delete_unique(u'news_dailysummary', ['date', 'category', 'edition'])

        # Deleting model 'DailySummary'
        db.delete_table(u'news_dailysummary')

        # Deleting model 'NewsDetail'
        db.delete_table(u'news_newsdetail')

        # Deleting model 'NewsStocksMap'
        db.delete_table(u'news_newsstocksmap')

        # Deleting model 'NewsClusters'
        db.delete_table(u'news_newsclusters')

        # Deleting model 'ClusterSummary'
        db.delete_table(u'news_clustersummary')

        # Deleting model 'StockSummary'
        db.delete_table(u'news_stocksummary')


    models = {
        u'basic_info.stock': {
            'Meta': {'object_name': 'Stock'},
            'code': ('django.db.models.fields.CharField', [], {'max_length': '8', 'primary_key': 'True'}),
            'csrc_industry': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
            'csrc_sub_industry': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'full_name': ('django.db.models.fields.CharField', [], {'max_length': '100', 'blank': 'True'}),
            'pinyin_name': ('django.db.models.fields.CharField', [], {'max_length': '20'}),
            'short_name': ('django.db.models.fields.CharField', [], {'max_length': '20', 'db_index': 'True'})
        },
        u'news.clustersummary': {
            'Meta': {'unique_together': "(('daily_summary', 'cluster_id'),)", 'object_name': 'ClusterSummary'},
            'cluster_id': ('django.db.models.fields.IntegerField', [], {}),
            'daily_summary': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['news.DailySummary']"}),
            'display_news': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['news.NewsDetail']"}),
            'doc_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'keywords': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
            'negative_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'neutral_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'positive_count': ('django.db.models.fields.IntegerField', [], {'default': '0'})
        },
        u'news.dailysummary': {
            'Meta': {'unique_together': "(('date', 'category', 'edition'),)", 'object_name': 'DailySummary'},
            'category': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
            'date': ('django.db.models.fields.DateField', [], {}),
            'doc_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'domain_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'edition': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'negative_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'neutral_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'positive_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'top_keywords': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'})
        },
        u'news.newsclusters': {
            'Meta': {'unique_together': "(('news', 'edition', 'cluster_id'),)", 'object_name': 'NewsClusters'},
            'cluster_id': ('django.db.models.fields.IntegerField', [], {}),
            'edition': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'news': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['news.NewsDetail']"})
        },
        u'news.newsdetail': {
            'Meta': {'unique_together': "(('date', 'category', 'url_hash'),)", 'object_name': 'NewsDetail', 'index_together': "[['date', 'category']]"},
            'add_succeeded': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
            'category': ('django.db.models.fields.CharField', [], {'max_length': '10'}),
            'date': ('django.db.models.fields.DateField', [], {'db_index': 'True'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'keywords': ('django.db.models.fields.CharField', [], {'max_length': '200', 'blank': 'True'}),
            'polarity': ('django.db.models.fields.IntegerField', [], {'default': '-1'}),
            'published_time': ('django.db.models.fields.DateTimeField', [], {}),
            'publisher': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
            'related_stocks': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['basic_info.Stock']", 'through': u"orm['news.NewsStocksMap']", 'symmetrical': 'False'}),
            'static_summary': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
            'title': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
            'url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
            'url_hash': ('django.db.models.fields.CharField', [], {'max_length': '32', 'db_index': 'True'})
        },
        u'news.newsstocksmap': {
            'Meta': {'unique_together': "(('news', 'stock'),)", 'object_name': 'NewsStocksMap'},
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'news': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['news.NewsDetail']"}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        },
        u'news.stocksummary': {
            'Meta': {'unique_together': "(('stock', 'date', 'edition'),)", 'object_name': 'StockSummary'},
            'date': ('django.db.models.fields.DateField', [], {}),
            'doc_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'edition': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
            'negative_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'neutral_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'positive_count': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
            'stock': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['basic_info.Stock']"})
        }
    }

    complete_apps = ['news']